﻿using System.Globalization;
using System.Windows;
using System.Windows.Markup;
using System.Threading;
using System;

namespace CoTime
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        static App()
        {
            // Ensure the current culture passed into bindings is the OS culture.
            // By default, WPF uses en-US as the culture, regardless of the system settings.
            //
            FrameworkElement.LanguageProperty.OverrideMetadata(
              typeof(FrameworkElement),
              new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
        }
        
        private Mutex mutex;

        protected override void OnStartup(StartupEventArgs theArgs)
        {
            Boolean isNewInstance = false;
            mutex = new Mutex(true, "CoTime", out isNewInstance);
            if (!isNewInstance)
            {
                App.Current.Shutdown();
            }
        }
    }
}
